#include "acl/ops/acl_dvpp.h"
#include "acl/acl.h"
#include <iostream>


#define YUV420SP_SIZE(width, height) ((width) * (height) * 3 / 2)

class DVPP_VPC
{

private:
    /* data */
    aclrtContext g_context_;
    aclrtStream g_stream_;

    acldvppRoiConfig  *g_cropConfig_; 
    acldvppJpegeConfig *g_jpegeConfig_;
    acldvppResizeConfig *g_resizeConfig_;

    acldvppPicDesc *g_vpcInputDesc_; // resize input desc
    acldvppPicDesc *g_vpcOutputDesc_; // resize output desc
    acldvppPicDesc *g_cropInputDesc_;   //crop输入
    acldvppPicDesc *g_cropOutputDesc_;  //crop输出

    acldvppChannelDesc *g_dvppChannelDesc_;

    acldvppPicDesc *encodeInputDesc_;

    uint32_t g_inputBufferSize_;
    uint32_t g_OutputBufferSize_;
    

public:
    DVPP_VPC(/* args */);
    ~DVPP_VPC();

    void *g_vpcOutBufferDev_;
    void *encodeOutBufferDev_;
    void *g_cropOutBufferDev_;

    int dvppInit();

    int dvpp_resize(unsigned char * srcImage,  uint32_t len, int input_w, int input_h, int output_w, int output_h);//输入YUV要求宽16对齐，高2对齐
    int dvpp_jpege(unsigned char * srcImage, uint32_t len, int input_w, int input_h);

    int dvpp_resize_jpege();

    int dvpp_crop(unsigned char * srcImage, uint32_t len, int input_w, int input_h, int top_x, int top_y, int output_w, int output_h);
    
    // int dvpp_crop(unsigned char * srcImage);

    void dvpp_resizeUninit();
    void dvpp_jpegeUninit();
    void dvpp_cropUninit();
};

